import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
/* layout */
import Layout from '../views/layout/Layout'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)
//路由列表
export const constantRouterMap = [
    { path: '/login', component: _import('login/index'), hidden: true },
    { path: '/404', component: _import('404'), hidden: true },
    {
        path: '/',
        component: Layout,
        redirect: '/home/index',
        hidden: true,
        name: 'admin',
        children: [
            { path: '/listsNum', component: _import('dashboard/index'),name:'大数据' },
            { path: '/dashboard', component: _import('home/index'),name:'首页' },
        ]
    }
]
export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})
export const asyncRouterMap=[       //异步路由
    { path: '*', redirect: '/404', hidden: true }
]
